ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Predators.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
33 //---------------------------------------------------------------------------
34 #ifndef PredatorsH
35 #define PredatorsH
36 //---------------------------------------------------------------------------
37 
38 //---------------------------------------------------------------------------
39 
40 class TPredator;
42 
43 //------------------------------------------------------------------------------
47 //typedef vector<TPredator*> TListOfPredators;
48 //---------------------------------------------------------------------------
49 
53 typedef enum
54 {
60 
66 {
67  public:
68  int x;
69  int y;
70  int species;
73 };
74 
87 class TPredator : public TAnimal
88 {
89  /*
90  A predator must have some simple functionality:
91 
92  Search Area: where it looks for prey
93  HomeRange: containing all its current search areas
94  Kill Efficiency: How good it is at finding and killing prey
95  Movement: How much it moves around in its home range
96  Dispersal: How often and how it changes its home range
97  */
98 
99  // Inherits m_Location_x, m_Location_y, m_OurLandscape from TAnimal
100  // NB All areas are squares of size length X length
101 
102 protected:
104  unsigned SpeciesID;
105  unsigned m_DispersalMax;
106  unsigned m_SearchArea;// length of side of a square area
112  int SimW;
113  int SimH;
114  unsigned m_FailureCount;
116  unsigned m_HomeRange; // TL corner = m_Location_x,m_Location_y
118  int m_KillEfficiency; // 0-1000 = 0-100%
121  vector<Vole_Base*>* CurrentPrey;
122 public:
123  TPredator(Vole_Population_Manager* ThePrey, int p_x, int p_y,
125  ~TPredator();
126  bool OverlapMyTerritory(unsigned x, unsigned y);
127  virtual void st_Dispersal();
128  virtual void st_Movement();
129  virtual int st_Hunting();
130  virtual void BeginStep (void) {}
131  virtual void Step (void) {}
132  virtual void EndStep (void) {}
133 
134  unsigned SupplySpeciesID() {return SpeciesID;}
136  bool SupplyTerr() {return m_HaveTerritory;}
138  int SupplyHomeRange() {return m_HomeRange;}
139 };
140 
146 {
147 public:
148 // Methods
149  virtual void Run(int);
150  bool InOtherTerritory(unsigned sp, int p_x, int p_y, TPredator* p_Pred);
152  virtual ~TPredator_Population_Manager (void);
153  void CreateObjects(int ob_type, TAnimal *pvo,/*void* null ,*/
154  struct_Predator* data,int number);
155  void inc_inds(unsigned list) {m_no_individuals[list]++;}
156  void dec_inds(unsigned list) {m_no_individuals[list]--;}
157  unsigned supply_no_inds(unsigned list) {return m_no_individuals[list];}
158 
159 protected:
160 // Attributes
162  unsigned NoPredatorTypes;
163  unsigned m_no_individuals[2];
164 
165 // Methods
166  virtual bool StepFinished();
167  virtual void DoFirst(){}
168  virtual void DoBefore(){}
169  virtual void DoAfter(){}
170  virtual void DoLast(){}
171  void CloseTheReallyBigOutputProbe() {}; // This will always be done by the main population manager
172  virtual void CloseTheRipleysOutputProbe() {}; // This will always be done by the main population manager
173  void PredSampleFile();
174  void PredAutumnSample();
175  void PredSpringSample();
176  void PredSpringAutumnSample();
177 
178 };
179 
187 class Weasel : public TPredator
188 {
189 public:
190 // virtual void st_Movement() {};
191 // virtual int st_Hunting() {};
192 // virtual void st_Dispersal() {};
193  virtual void BeginStep (void);
194  virtual void Step (void);
195  virtual void EndStep (void) {}
196  Weasel(Vole_Population_Manager* ThePrey, int p_x, int p_y, Landscape * p_L,
198  virtual ~Weasel();
199 };
200 
208 class Owl : public TPredator
209 {
210  public:
211 // virtual void st_Movement() {};
212 // virtual void st_Hunting() {};
213 // virtual void st_Dispersal() {};
214  virtual void BeginStep (void);
215  virtual void Step (void);
216  virtual void EndStep (void) {}
217  Owl(Vole_Population_Manager* ThePrey, int p_x, int p_y, Landscape * p_L,
219  virtual ~Owl();
220 };
221 
222 //---------------------------------------------------------------------------
223 #endif
TTypeOfPredatorState
Definition: Predators.h:54
@ tops_Dispersal
Definition: Predators.h:57
@ tops_Hunting
Definition: Predators.h:56
@ tops_Movement
Definition: Predators.h:58
@ tops_InitialState
Definition: Predators.h:55
The landscape class containing all environmental and topographical data.
Definition: landscape.h:113
The Owl class is one of two current implementations of TPredator.
Definition: Predators.h:209
virtual void EndStep(void)
EndStep behaviour - must be implemented in descendent classes.
Definition: Predators.h:216
virtual void BeginStep(void)
BeingStep behaviour - must be implemented in descendent classes.
Definition: Predators.cpp:933
virtual void Step(void)
Step behaviour - must be implemented in descendent classes.
Definition: Predators.cpp:967
Owl(Vole_Population_Manager *ThePrey, int p_x, int p_y, Landscape *p_L, TPredator_Population_Manager *p_PPM)
Definition: Predators.cpp:917
virtual ~Owl()
Definition: Predators.cpp:1005
Base class for all population managers.
Definition: PopulationManager.h:424
The base class for all ALMaSS animal classes.
Definition: PopulationManager.h:205
The class to handle all predator population related matters.
Definition: Predators.h:146
bool InOtherTerritory(unsigned sp, int p_x, int p_y, TPredator *p_Pred)
Definition: Predators.cpp:671
void inc_inds(unsigned list)
Definition: Predators.h:155
virtual void DoLast()
Definition: Predators.h:170
void dec_inds(unsigned list)
Definition: Predators.h:156
unsigned m_no_individuals[2]
Definition: Predators.h:163
Vole_Population_Manager * m_Prey
Definition: Predators.h:161
void CreateObjects(int ob_type, TAnimal *pvo, struct_Predator *data, int number)
Definition: Predators.cpp:137
virtual void Run(int)
Definition: Predators.cpp:553
void PredSpringSample()
Definition: Predators.cpp:423
virtual bool StepFinished()
Overrides the population manager StepFinished - there is no chance that hunters do not finish a step ...
Definition: Predators.cpp:655
virtual void DoAfter()
Definition: Predators.h:169
virtual void CloseTheRipleysOutputProbe()
Definition: Predators.h:172
unsigned supply_no_inds(unsigned list)
Definition: Predators.h:157
virtual void DoBefore()
Definition: Predators.h:168
void PredAutumnSample()
Definition: Predators.cpp:360
unsigned NoPredatorTypes
Definition: Predators.h:162
void PredSpringAutumnSample()
Definition: Predators.cpp:486
TPredator_Population_Manager(Landscape *L, Vole_Population_Manager *VPM)
Definition: Predators.cpp:89
virtual void DoFirst()
Definition: Predators.h:167
void PredSampleFile()
Definition: Predators.cpp:161
virtual ~TPredator_Population_Manager(void)
Definition: Predators.cpp:83
void CloseTheReallyBigOutputProbe()
Definition: Predators.h:171
The base class for predators encompsassing all their general behaviours.
Definition: Predators.h:88
int m_Search_x
Definition: Predators.h:110
unsigned m_HomeRange
Definition: Predators.h:116
TPredator_Population_Manager * m_OurPopulationManager
Definition: Predators.h:120
int m_Search_y
Definition: Predators.h:111
~TPredator()
Definition: Predators.cpp:719
vector< Vole_Base * > * CurrentPrey
Definition: Predators.h:121
int m_KillEfficiency
Definition: Predators.h:118
virtual void EndStep(void)
EndStep behaviour - must be implemented in descendent classes.
Definition: Predators.h:132
virtual int st_Hunting()
Definition: Predators.cpp:726
int SupplyHomeRange()
Definition: Predators.h:138
virtual void st_Dispersal()
Definition: Predators.cpp:787
bool OverlapMyTerritory(unsigned x, unsigned y)
Definition: Predators.cpp:770
int SimH
Definition: Predators.h:113
int SupplyKill()
Definition: Predators.h:135
TPredator(Vole_Population_Manager *ThePrey, int p_x, int p_y, Landscape *p_L, TPredator_Population_Manager *p_PPM)
Definition: Predators.cpp:696
Vole_Population_Manager * m_Prey
Definition: Predators.h:119
unsigned m_NoFailuresBeforeDispersal
Definition: Predators.h:115
int PreyResponse2
Definition: Predators.h:109
unsigned m_SearchArea
Definition: Predators.h:106
int SupplyKillEff()
Definition: Predators.h:137
bool SupplyTerr()
Definition: Predators.h:136
TTypeOfPredatorState CurrentPState
Definition: Predators.h:103
unsigned SpeciesID
Definition: Predators.h:104
virtual void BeginStep(void)
BeingStep behaviour - must be implemented in descendent classes.
Definition: Predators.h:130
int PreyResponse1
Definition: Predators.h:108
unsigned m_FailureCount
Definition: Predators.h:114
unsigned m_DispersalMax
Definition: Predators.h:105
unsigned SupplySpeciesID()
Definition: Predators.h:134
virtual void st_Movement()
Definition: Predators.cpp:753
int SimW
Definition: Predators.h:112
virtual void Step(void)
Step behaviour - must be implemented in descendent classes.
Definition: Predators.h:131
bool m_HaveTerritory
Definition: Predators.h:117
int m_kills_this_season
Definition: Predators.h:107
The class to handle all vole population related matters.
Definition: VolePopulationManager.h:152
The Weasel class is one of two current implementations of TPredator.
Definition: Predators.h:188
virtual void EndStep(void)
EndStep behaviour - must be implemented in descendent classes.
Definition: Predators.h:195
virtual ~Weasel()
Definition: Predators.cpp:833
virtual void Step(void)
Step behaviour - must be implemented in descendent classes.
Definition: Predators.cpp:873
virtual void BeginStep(void)
BeingStep behaviour - must be implemented in descendent classes.
Definition: Predators.cpp:839
Weasel(Vole_Population_Manager *ThePrey, int p_x, int p_y, Landscape *p_L, TPredator_Population_Manager *p_PPM)
Definition: Predators.cpp:816
Used for creation of a new predator object.
Definition: Predators.h:66
Landscape * L
Definition: Predators.h:71
TPredator_Population_Manager * PM
Definition: Predators.h:72
int species
Definition: Predators.h:70
int x
Definition: Predators.h:68
int y
Definition: Predators.h:69